/*
 * @Author: your name
 * @Date: 2022-01-29 19:43:44
 * @LastEditTime: 2022-02-02 23:14:36
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3-vite-tsx\src\store\index.ts
 */
import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import getters from './getters'

// webpack 可用 vite 不行..
let modules = {}
const modulesFiles = import.meta.globEager('./modules/*.ts')
for (const path in modulesFiles) {
  const moduleName = path.replace(/(.*\/)*([^.]+).*/gi, '$2')
  modules = { ...modules, [moduleName]: modulesFiles[path].default }
}

const store = createStore({
  getters,
  modules,
  plugins: [createPersistedState()]
})
export default store
// console.log('store: ', store);
